
layui.use(['element', 'table', 'form', 'layer','jquery','upload'], function () {
    var element = layui.element;
    var $ = layui.jquery;
    var form = layui.form;
    var layer = layui.layer;
    var table = layui.table;
    var upload = layui.upload;
    //获取登录人
    var createId = localStorage.getItem('createId');
    /*点击修改开始*/
    wancheng = function wancheng() {
        var productCode = $('input[name=productCode]').val();
        var currentpriceProduct = $('input[name=currentpriceProduct]').val();
        var bCode = isNaN(productCode);
        var bPrice = isNaN(currentpriceProduct);
        //校验
        if (productCode==''|bCode==true|currentpriceProduct==''|bPrice==true){
            return;
        }

        var updata = $('#update').serialize();
        updata = updata+'&updateId='+createId;
        $.ajax({
            url: "/goodsTable/updateProduct",
            data: updata,
            type: "post",
            dataType: 'json',
            success: function (data) {
                window.parent.location.reload();
                var layers = parent.layer;
                layers.close(layers.index);
            }
        })
    }
    /*点击修改结束*/
    //修改图片
    upload.render({
        elem:'#mainImage',
        url: "/upload/uploadFile",
        field: "files",
        accept: "images",
        acceptMime: 'image/*',
        done: function (res, index, upload) {
            if (res.code == 0) {
                var mainImage = res.data.path;
                $('#mainImage').attr('src', mainImage);
                $('input[name=mainImage]').val(mainImage);
            }
        },
        progress: function (n, elem, e) {
            element.progress('demo', n + '%');
            if (n == 100) {
                layer.msg('上传完毕', {icon: 1});
            }
        }
    });
    /*取消开始*/
    quxiao = function quxiao() {
        var layers = parent.layer;
        layers.close(layers.index);
    }
    /*取消结束*/
});